package com.ruoyi.system.controller;

import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.system.api.domain.SysUserWork;
import com.ruoyi.system.service.ISysUserWorkService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 用户工作经历
 *
 * @author ruoyi
 */
@Api(tags = "用户工作经历")
@RestController
@RequestMapping("/user/work")
public class SysUserWorkController extends BaseController {

    @Autowired
    private ISysUserWorkService sysUserWorkService;

    /**
     * 获取用户工作经历列表
     */
    @GetMapping("/list")
    @ApiOperation(value = "获取用户工作经历列表", response = SysUserWork.class)
    public AjaxResult list(SysUserWork sysUserWork) {
        List<SysUserWork> list = sysUserWorkService.selectUserWorkList(sysUserWork);
        return success(list);
    }

    /**
     * * 详情接口
     *
     * @param workId
     * @return
     */
    @GetMapping("/{workId}")
    @ApiOperation(value = "获取用户工作经历列表", response = SysUserWork.class)
    public AjaxResult getInfo(@ApiParam(value = "用户经历id", required = true) @PathVariable Long workId) {
        return success(sysUserWorkService.selectSysUserWorkByWorkId(workId));
    }

    /**
     * 新增用户工作经历
     */
    @Log(title = "新增用户工作经历", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增用户工作经历")
    public AjaxResult add(@RequestBody SysUserWork sysUserWork) {
        return success(sysUserWorkService.insertWork(sysUserWork));
    }

    /**
     * 删除用户工作经历
     */
    @Log(title = "删除用户工作经历", businessType = BusinessType.DELETE)
    @DeleteMapping("/delete/{workIds}")
    @ApiOperation("删除用户工作经历")
    public AjaxResult remove(@ApiParam(value = "用户经历id", required = true) @PathVariable Long[] workIds) {
        return toAjax(sysUserWorkService.deleteSysUserWorkByWorkIds(workIds));
    }
}
